home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / datash1a / frmdatas.frm < prev    next >
Text File  |  1999-10-09  |  5KB  |  149 lines

  1. VERSION 5.00
  2. Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
  3. Begin VB.Form frmDataShape 
  4.    Caption         =   "Data Shaping Basics"
  5.    ClientHeight    =   4890
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   7365
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4890
  11.    ScaleWidth      =   7365
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.ListBox List1 
  14.       Height          =   1230
  15.       ItemData        =   "frmDataShape.frx":0000
  16.       Left            =   480
  17.       List            =   "frmDataShape.frx":0002
  18.       TabIndex        =   1
  19.       Top             =   3210
  20.       Width           =   2445
  21.    End
  22.    Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1 
  23.       Bindings        =   "frmDataShape.frx":0004
  24.       Height          =   2535
  25.       Left            =   450
  26.       TabIndex        =   0
  27.       Top             =   360
  28.       Width           =   6465
  29.       _ExtentX        =   11404
  30.       _ExtentY        =   4471
  31.       _Version        =   393216
  32.       Cols            =   5
  33.       DataMember      =   "PhoneNumbers"
  34.       _NumberOfBands  =   2
  35.       _Band(0).Cols   =   4
  36.       _Band(0).GridLinesBand=   1
  37.       _Band(0).TextStyleBand=   0
  38.       _Band(0).TextStyleHeader=   0
  39.       _Band(0)._NumMapCols=   3
  40.       _Band(0)._MapCol(0)._Name=   "PhoneNumber"
  41.       _Band(0)._MapCol(0)._Caption=   "Phone Number"
  42.       _Band(0)._MapCol(0)._RSIndex=   0
  43.       _Band(0)._MapCol(1)._Name=   "Association"
  44.       _Band(0)._MapCol(1)._RSIndex=   1
  45.       _Band(0)._MapCol(2)._Name=   "Name"
  46.       _Band(0)._MapCol(2)._RSIndex=   2
  47.       _Band(1).BandIndent=   1
  48.       _Band(1).Cols   =   1
  49.       _Band(1).GridLinesBand=   1
  50.       _Band(1).TextStyleBand=   0
  51.       _Band(1).TextStyleHeader=   0
  52.       _Band(1)._ParentBand=   0
  53.       _Band(1)._NumMapCols=   2
  54.       _Band(1)._MapCol(0)._Name=   "Family"
  55.       _Band(1)._MapCol(0)._RSIndex=   0
  56.       _Band(1)._MapCol(1)._Name=   "PhoneNumber"
  57.       _Band(1)._MapCol(1)._RSIndex=   1
  58.       _Band(1)._MapCol(1)._Hidden=   -1  'True
  59.    End
  60.    Begin VB.Label Label1 
  61.       Caption         =   $"frmDataShape.frx":0023
  62.       Height          =   885
  63.       Left            =   3330
  64.       TabIndex        =   2
  65.       Top             =   3240
  66.       Width           =   3615
  67.    End
  68. End
  69. Attribute VB_Name = "frmDataShape"
  70. Attribute VB_GlobalNameSpace = False
  71. Attribute VB_Creatable = False
  72. Attribute VB_PredeclaredId = True
  73. Attribute VB_Exposed = False
  74. Option Explicit
  75. Dim blnLoadingForm As Boolean
  76. '*******************************************************************************************
  77. '* Written by Timothy A. Vanover 10/9/1999
  78. '* This project is meant to explore very basic data shaping, Hierarchical Recordsets.
  79. '* To gain the most of this project you must explore DataEnvironment1 throughly. There are
  80. '* several properties, queries, and relationships, and a connection object that you have
  81. '* to understand to make Hierarchical Recordsets, which the basics are explored here. Also
  82. '* a good look at the Access Database and the table relationship would help gain a good
  83. '* start on "Data Shaping".
  84. '*******************************************************************************************
  85.  
  86.  
  87. Private Sub Form_Load()
  88.     Dim i As Integer
  89.     
  90.     blnLoadingForm = True 'use to prevent List_Click From firing requery
  91.     
  92.     With MSHFlexGrid1 'set Column widths
  93.         .ColWidth(0, 0) = 400
  94.         .ColWidth(1, 0) = 1500
  95.         .ColWidth(2, 0) = 1500
  96.         .ColWidth(3, 0) = 1500
  97.         .ColWidth(0, 1) = 1500
  98.     End With
  99.         
  100.     With DataEnvironment1
  101.         .rsAssociations.Open
  102.         If Not .rsAssociations.BOF Then 'check for BOF or EOF before moving
  103.             .rsAssociations.MoveFirst
  104.             For i = 0 To .rsAssociations.RecordCount - 1
  105.                 List1.AddItem .rsAssociations!Association 'add record to listbox
  106.                 If Not .rsAssociations.EOF Then
  107.                     .rsAssociations.MoveNext 'move to next record
  108.                 End If
  109.             Next i
  110.         End If
  111.         
  112.     End With
  113.     
  114.     blnLoadingForm = False
  115.     
  116. End Sub
  117.  
  118. Private Sub Form_Unload(Cancel As Integer)
  119.     'just a bit of cleanup
  120.     With DataEnvironment1
  121.         .rsAssociations.Close
  122.         .rsPhoneNumbers.Close
  123.         .Connection1.Close
  124.     End With
  125.     Set DataEnvironment1 = Nothing
  126. End Sub
  127.  
  128. Private Sub List1_Click()
  129.     'closing the recordset may not be needed. There is a Filter, and a requery
  130.     'I wanted to show the Changing of a named Parameter value which requires
  131.     'the recordset to be closed.
  132.     If Not blnLoadingForm Then
  133.     
  134.         With DataEnvironment1
  135.             .rsPhoneNumbers.Close
  136.             .Commands.Item("PhoneNumbers").Parameters("Association").Value = Trim$(List1.Text)
  137.             .Commands.Item("PhoneNumbers").Execute
  138.         End With
  139.     
  140.         With MSHFlexGrid1
  141.            Set .DataSource = Nothing
  142.            Set .DataSource = DataEnvironment1
  143.            .DataMember = "PhoneNumbers"
  144.         End With
  145.         
  146.     End If
  147.     
  148. End Sub
  149.